<%--
  Created by IntelliJ IDEA.
  User: hysio
  Date: 2020/5/17
  Time: 9:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>软件测试工程师管理系统 - 修改工程师</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body class="layui-layout-body">

<%
    if(session.getAttribute("user") == null)
    {
        response.sendRedirect("login.jsp");
    }
%>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">软件测试工程师管理系统</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <%=session.getAttribute("user")%>
                </a>
            </li>
            <li class="layui-nav-item"><a href="login.jsp">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item"><a href="index.jsp">首页</a></li>
                <li class="layui-nav-item"><a href="insert.jsp">添加工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">查询工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">修改工程师</a></li>
                <li class="layui-nav-item"><a href="select.jsp">删除工程师</a></li>
                <li class="layui-nav-item"><a href="history.jsp">操作记录</a></li>
                <li class="layui-nav-item"><a href="calculate.jsp">薪水计算</a></li>
                <li class="layui-nav-item"><a href="sort.jsp">资料排序</a></li>
                <li class="layui-nav-item"><a href="empty.jsp">清空资料</a></li>
                <li class="layui-nav-item"><a href="print.jsp">打印报表</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="layui-tab-item layui-show">
            <div class="layui-main">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>修改工程师</legend>
                </fieldset>
                <form class="layui-form layui-form-pane" action="/idea_project_war_exploded/Update" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">ID</label>
                        <div class="layui-input-inline">
                            <input type="text" name="id" readonly unselectable="on" autocomplete="off" class="layui-input" maxlength="20"
                                   value=<%=session.getAttribute("id")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input" maxlength="20"
                                   value=<%=session.getAttribute("name")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <%if(session.getAttribute("sex").toString().equals("男")){%>
                            <input type="radio" name="sex" value="男" title="男" checked="" >
                            <input type="radio" name="sex" value="女" title="女">
                            <%}
                            else {%>
                            <input type="radio" name="sex" value="男" title="男"  >
                            <input type="radio" name="sex" value="女" title="女" checked="">
                            <%}%>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">生日</label>
                            <div class="layui-input-block">
                                <input type="text" name="birth" id="date1" autocomplete="off" class="layui-input" lay-verify="required"
                                       value=<%=session.getAttribute("birth")%>>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">学历</label>
                            <div class="layui-input-inline">
                                <select name="degree" id="degree" lay-verify="required">
                                    <option value="">请选择学历</option>
                                    <optgroup label="初等教育">
                                        <option value="小学">小学</option>
                                    </optgroup>
                                    <optgroup label="中等教育">
                                        <option value="初中">初中</option>
                                        <option value="高中">高中</option>
                                        <option value="中专">中专</option>
                                        <option value="职校">职校</option>
                                    </optgroup>
                                    <optgroup label="高等教育">
                                        <option value="专科">专科</option>
                                        <option value="本科">本科</option>
                                        <option value="硕士">硕士</option>
                                        <option value="博士">博士</option>
                                    </optgroup>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">籍贯</label>
                        <div class="layui-input-inline">
                            <input type="text" name="origin" lay-verify="required" autocomplete="off" class="layui-input" maxlength="10"
                                   value=<%=session.getAttribute("origin")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="address" lay-verify="address" autocomplete="off" class="layui-input" maxlength="30"
                                   value=<%=session.getAttribute("address")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-inline">
                            <input type="text" name="tel" lay-verify="tel" autocomplete="off" class="layui-input" maxlength="15"
                                   onkeyup="value=value.replace(/[^0-9-]+/,'')"
                                   value=<%=session.getAttribute("tel")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">工龄</label>
                        <div class="layui-input-inline">
                            <input type="text" name="wyear" lay-verify="required" autocomplete="off" class="layui-input"
                                   onkeyup="onlyNumber(this)" onblur="onlyNumber(this)" oninput="if(value>50)value=50"
                                   value=<%=session.getAttribute("wyear")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">工资</label>
                        <div class="layui-input-inline">
                            <input type="text" name="wage" lay-verify="required" autocomplete="off" class="layui-input" maxlength="7"
                                   onkeyup="onlyNumber(this)" onblur="onlyNumber(this)"
                                   value=<%=session.getAttribute("wage")%>>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

</div>
<script src="layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            // address: function(value){
            //     if(value.length < 6){
            //         return '地址不能少于6位';
            //     }
            // }
            // ,pass: [
            //     /^[\S]{6,12}$/
            //     ,'密码必须6到12位，且不能出现空格'
            // ]
            // ,tel: function(value){
            //     if(value.length != 11){
            //         return '联系方式需为11位';
            //     }
            // }
            content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.msg('修改成功！');
            $.ajax({
                url:'/idea_project_war_exploded/Insert',
                type:'post',
                data:data.field,
                dataType:"text",
                success:function(data){
                    if(data){
                        layer.alert("修改成功")
                    }
                    else{
                        layer.alert("修改失败")
                    }
                },
                error:function(e){
                    layer.alert("修改失败")
                },

            });
        });

        //下拉框赋值
        layui.$("#degree").find("option[value=<%=session.getAttribute("degree")%>]").prop("selected",true);
        form.render();

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function(){
            form.val('example', {
                "username": "贤心" // "name": "value"
                ,"password": "123456"
                ,"interest": 1
                ,"like[write]": true //复选框选中状态
                ,"close": true //开关状态
                ,"sex": "女"
                ,"desc": "我爱 layui"
            });
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function(){
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

    });
</script>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
</script>
<script language="JavaScript" >
    function onlyNumber(obj){
//得到第一个字符是否为负号
        var t = obj.value.charAt(0);
//先把非数字的都替换掉，除了数字和.
        obj.value = obj.value.replace(/[^\d\.]/g,'');
//必须保证第一个为数字而不是.
        obj.value = obj.value.replace(/^\./g,'');
//保证只有出现一个.而没有多个.
        obj.value = obj.value.replace(/\.{2,}/g,'.');
//保证.只出现一次，而不能出现两次以上
        obj.value = obj.value.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
//如果第一位是负号，则允许添加
//         if(t == '-'){
//             obj.value = '-'+obj.value;
//         }
    }
</script>
</body>
</html>